package com.transcoachapp.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.transcoachapp.BusesPassStation;
import com.transcoachapp.R;
import com.transcoachapp.data.BusStationDetail;
import com.transcoachapp.data.RailStation;

public class RailStationAdapter extends ArrayAdapter<RailStation>{
	private Activity context;
	private ArrayList<RailStation> items;
	TextView route;
	String substr;
	public RailStationAdapter(Context context, int textViewResourceId,
			ArrayList<RailStation> objects) {
		super(context, textViewResourceId, objects);
		this.items = objects;
		this.context = (Activity) context;
		// TODO Auto-generated constructor stub
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if (this.items != null)
		      return this.items.size();
		return 0;
	}
	@Override
	public RailStation getItem(int arg0) {
		// TODO Auto-generated method stub
		return this.items.get(arg0);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{   // Ordinary view in Spinner, we use android.R.layout.simple_spinner_item
		
		final RailStation bs  = getItem(position);
		View bsdRow = context.getLayoutInflater().inflate(R.layout.ferry_line, null);
	/*	bsdRow.setClickable(true);
		bsdRow.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
                intent.setClass(context, BusesPassStation.class);
                intent.putExtra("stationCode", bs.getStationOrder());
                intent.putExtra("stationName", bs.getStationName());
				context.startActivity(intent);		
				
			}
		});
		*/
		TextView routeName = (TextView) bsdRow.findViewById(R.id.ferryName);
		routeName.setText(bs.getStationOrder()+" - "+bs.getStationName());
		return bsdRow;
	}
}
